<?php
    include_once('../../src/classes/class.mssql.php');
    
    $comtec_id_owner = $_GET['id'];
   
    $db = new MSSQL();
    
    $texto = "SELECT cod_owner,
		     company_name,
		     rut,
		     address,
		     contact_name,
                     phone,
		     contact_lastname1,            
                     contact_lastname2,
		     contact_position,                   
		     email
		     FROM owner
                     WHERE comtec_id_owner=".$comtec_id_owner;
    
    $result = $db->fetch_array($db->query($texto));  
   
    $cod_owner=$result['cod_owner'];
    $phone = $result['phone'];
    
    $contact_name = $result['contact_name'];
    $contact_lastname1 = $result['contact_lastname1'];
    $contact_lastname2 = $result['contact_lastname2'];
    $contact_position  = $result['contact_position'];  
    
    $rut = $result['rut'];   
    $rut_cod = substr($rut, -1, 1);
    $rut = substr($rut,0,strlen($rut)-1);
    
    $company_name = $result['company_name'];
    $address = $result['address'];
    
    $email = $result['email'];
?>
<fieldset class="curved">
 <legend>Editar</legend>
  <table style="margin: 10px auto; border-spacing: 10px;">
   <tr>
    <td width="200">Codigo</td>
    <td><input type="text" size="40" maxlength="10" id="cod_owner" value="<?=$cod_owner;?>" /></td>
    <td width="200">Nombre</td>
    <td><input type="text" size="40" maxlength="150" id="company_name" value="<?=$company_name;?>" /></td>
   </tr>  
   <tr>
    <td width="200">RUT</td>
    <td><input type="text" id="rut" size="34" maxlength="8" value="<?=$rut;?>" />-<input type="text" id="rut_cod" size="1" maxlength="1" value="<?=$rut_cod;?>" /></td>
    <td width="200">Direcci&oacute;n</td>
    <td><input type="text" id="address" size="40" maxlength="400" value="<?=$address;?>" /></td>
   </tr>
   <tr>
    <td width="200">Nombre Contacto</td>
    <td><input type="text" id="contact_name" size="40" maxlength="50" value="<?=$contact_name;?>" /></td>
    <td width="200">Apellido Paterno Contacto</td>
    <td><input type="text" id="contact_lastname1" size="40" maxlength="50" value="<?=$contact_lastname1;?>" /></td>
    <td width="200">Apellido Materno Contacto</td>
    <td><input type="text" id="contact_lastname2" size="40" maxlength="50" value="<?=$contact_lastname2;?>" /></td>   
   </tr>
   <tr>
    <td width="200">Cargo Contacto</td>
    <td><input type="text" size="40" maxlength="150" id="contact_position" value="<?=$contact_position;?>" /></td>
     <td width="200">Tel&eacute;fono Contacto</td>
    <td><input type="text" size="40" maxlength="20" id="phone" value="<?=$phone;?>" /></td>
   </tr>
   <tr>
    <td width="200">Correo electr&oacute;nico</td>
    <td><input type="text" size="40" maxlength="100" id="email" value="<?=$email;?>" /></td>   
   </tr>
    <tr>
     <td>
         <input type="button" id="edit" value="Editar" onclick="javascript:editOwner(<?=$comtec_id_owner;?>)" />
     </td>
     <td>
         <input type="button" value="Cancelar" onclick="javascript:loadOwners();" />
     </td>    
    </tr>
    </table>
 <div id="result"></div> 
</fieldset>